import {BasicColumn, FormSchema} from '/@/components/Table';
import {rules} from '/@/utils/helper/validator';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '题库名称',
    align: "center",
    dataIndex: 'title',
    slots: {customRender: 'title'}
  },
  {
    title: '题库编码',
    align: "center",
    dataIndex: 'code'
  },
  {
    title: '试题数量',
    align: "center",
    dataIndex: 'num'
  },
  {
    title: '题库备注',
    align: "center",
    dataIndex: 'remark'
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'title',
    label: '题库名称',
    component: 'JInput',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '题库名称',
    field: 'title',
    required: true,
    component: 'Input',
  },
  {
    label: '题库编码',
    field: 'code',
    required: true,
    component: 'Input',
    dynamicDisabled: ({ values }) => {
      return !!values.id;
    },
    dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('repository', 'code', model, schema, true),
  },
  {
    label: '题库备注',
    field: 'remark',
    component: 'Input',
  },
];


/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
